<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>

<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <base href="<%=basePath%>">
    
    <title>用户登录</title>
    
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">    
	<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
	<meta http-equiv="description" content="This is my page">
	
	<link rel="stylesheet" type="text/css" href="css/dengru.css">
	<script type="text/javascript">
		function jiaoyan(){
		
		var username = document.getElementById("usernameId").value;
		
		var password = document.getElementById("passwordId").value;
		
			var xmlhttp=new XMLHttpRequest();
			
			xmlhttp.onreadystatechange = function(){
				if(xmlhttp.readyState==4){
					
					var data=xmlhttp.responseText;
				
					if(data == "false"){
						alert("用户名或密码错误");
						
					}else if(data == "true"){
						window.location.href="welcome.jsp";
					}
				}
			
			};
			xmlhttp.open("post","show_user.do",true);
			xmlhttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
			xmlhttp.send("username="+username+"&password="+password);
		
		}
		
	</script>

  </head>
  
  <body>
   	<div class="background_dengru">
   		
   		<div class="dengru">
   			 <!--用户登录 -->
		   		<input type="text" id="usernameId" placeholder="用户名"/><br />
		   		<input type="password" id="passwordId" placeholder="密码"/><br />
		   		<input type="button" value="登录" style="width:80px; margin:30px 200px;" onclick="jiaoyan()" />
		   
	   	</div>
   		
   	</div>
  </body>
</html>
